#include "widget_funcc_smart_home.h"
#include "ui_widget_funcc_smart_home.h"


Widget_funcC_Smart_Home::Widget_funcC_Smart_Home(QWidget *parent) :
    QWidget(parent),
//    mus(nullptr),
    ui(new Ui::Widget_funcC_Smart_Home)
{
    ui->setupUi(this);

    mus = new musicplayer;
    ui->verticalSlider->setRange(0,100);
    ui->verticalSlider->setValue(50);

    mp4player = new QMediaPlayer(this);
    mp4player->setMedia(QUrl::fromLocalFile("F:\\QTprint\\jqm\\mp3.MP3"));

    //mp4player->play();

    mp4timer=new QTimer(this);
    mp4timer->setInterval(60);
    mp4timer->setTimerType(Qt::PreciseTimer);
    mp4add = 0;
    m_mp4[0].load("F:\\QTprint\\MP3\\chuanq-100.png");
    m_mp4[1].load("F:\\QTprint\\MP3\\chuanq-101.png");
    m_mp4[2].load("F:\\QTprint\\MP3\\chuanq-102.png");
    m_mp4[3].load("F:\\QTprint\\MP3\\chuanq-103.png");
    m_mp4[4].load("F:\\QTprint\\MP3\\chuanq-104.png");
    m_mp4[5].load("F:\\QTprint\\MP3\\chuanq-105.png");
    m_mp4[6].load("F:\\QTprint\\MP3\\chuanq-106.png");
    m_mp4[7].load("F:\\QTprint\\MP3\\chuanq-107.png");
    m_mp4[8].load("F:\\QTprint\\MP3\\chuanq-108.png");
    m_mp4[9].load("F:\\QTprint\\MP3\\chuanq-109.png");
    m_mp4[10].load("F:\\QTprint\\MP3\\chuanq-110.png");
    m_mp4[11].load("F:\\QTprint\\MP3\\chuanq-111.png");
    m_mp4[12].load("F:\\QTprint\\MP3\\chuanq-112.png");
    m_mp4[13].load("F:\\QTprint\\MP3\\chuanq-113.png");
    m_mp4[14].load("F:\\QTprint\\MP3\\chuanq-114.png");
    m_mp4[15].load("F:\\QTprint\\MP3\\chuanq-115.png");
    m_mp4[16].load("F:\\QTprint\\MP3\\chuanq-116.png");
    m_mp4[17].load("F:\\QTprint\\MP3\\chuanq-117.png");
    m_mp4[18].load("F:\\QTprint\\MP3\\chuanq-118.png");
    m_mp4[19].load("F:\\QTprint\\MP3\\chuanq-119.png");
    m_mp4[20].load("F:\\QTprint\\MP3\\chuanq-120.png");
    m_mp4[21].load("F:\\QTprint\\MP3\\chuanq-121.png");
    m_mp4[22].load("F:\\QTprint\\MP3\\chuanq-122.png");
    m_mp4[23].load("F:\\QTprint\\MP3\\chuanq-123.png");
    m_mp4[24].load("F:\\QTprint\\MP3\\chuanq-124.png");
    m_mp4[25].load("F:\\QTprint\\MP3\\chuanq-125.png");
    m_mp4[26].load("F:\\QTprint\\MP3\\chuanq-126.png");
    m_mp4[27].load("F:\\QTprint\\MP3\\chuanq-127.png");
    m_mp4[28].load("F:\\QTprint\\MP3\\chuanq-128.png");
    m_mp4[29].load("F:\\QTprint\\MP3\\chuanq-129.png");
    m_mp4[30].load("F:\\QTprint\\MP3\\chuanq-130.png");
    m_mp4[31].load("F:\\QTprint\\MP3\\chuanq-131.png");
    m_mp4[32].load("F:\\QTprint\\MP3\\chuanq-132.png");
    m_mp4[33].load("F:\\QTprint\\MP3\\chuanq-133.png");
    m_mp4[34].load("F:\\QTprint\\MP3\\chuanq-134.png");

    mp4timer->start();
    connect(this->mp4timer,&QTimer::timeout,this,[=](){

        if(mp4add == 34){
            mp4add = 0;
        }
        ui->label_mp3->setPixmap(m_mp4[mp4add]);
        mp4add++;
          //qDebug() << "定时器时间到";
    });

    jqmtimer=new QTimer(this);
    jqmtimer->setInterval(60);
    jqmtimer->setTimerType(Qt::PreciseTimer);
    jqmadd = 0;
    m_jqm[0].load("F:\\QTprint\\jqm\\1.png");
    m_jqm[1].load("F:\\QTprint\\jqm\\2.png");
    m_jqm[2].load("F:\\QTprint\\jqm\\3.png");
    m_jqm[3].load("F:\\QTprint\\jqm\\4.png");
    m_jqm[4].load("F:\\QTprint\\jqm\\5.png");
    m_jqm[5].load("F:\\QTprint\\jqm\\6.png");
    m_jqm[6].load("F:\\QTprint\\jqm\\7.png");
    m_jqm[7].load("F:\\QTprint\\jqm\\8.png");
    m_jqm[8].load("F:\\QTprint\\jqm\\9.png");
    m_jqm[9].load("F:\\QTprint\\jqm\\10.png");
    m_jqm[10].load("F:\\QTprint\\jqm\\11.png");
    m_jqm[11].load("F:\\QTprint\\jqm\\12.png");
    m_jqm[12].load("F:\\QTprint\\jqm\\13.png");
    m_jqm[13].load("F:\\QTprint\\jqm\\14.png");
    m_jqm[14].load("F:\\QTprint\\jqm\\15.png");
    m_jqm[15].load("F:\\QTprint\\jqm\\16.png");
    m_jqm[16].load("F:\\QTprint\\jqm\\17.png");
    m_jqm[17].load("F:\\QTprint\\jqm\\18.png");
    m_jqm[18].load("F:\\QTprint\\jqm\\19.png");
    m_jqm[19].load("F:\\QTprint\\jqm\\20.png");
    m_jqm[20].load("F:\\QTprint\\jqm\\21.png");
    m_jqm[21].load("F:\\QTprint\\jqm\\22.png");
    m_jqm[22].load("F:\\QTprint\\jqm\\23.png");
    m_jqm[23].load("F:\\QTprint\\jqm\\24.png");
    m_jqm[24].load("F:\\QTprint\\jqm\\25.png");
    m_jqm[25].load("F:\\QTprint\\jqm\\26.png");
    m_jqm[26].load("F:\\QTprint\\jqm\\27.png");
    m_jqm[27].load("F:\\QTprint\\jqm\\28.png");
    m_jqm[28].load("F:\\QTprint\\jqm\\29.png");
    m_jqm[29].load("F:\\QTprint\\jqm\\30.png");
    m_jqm[30].load("F:\\QTprint\\jqm\\31.png");
    m_jqm[31].load("F:\\QTprint\\jqm\\32.png");
    m_jqm[32].load("F:\\QTprint\\jqm\\33.png");
    m_jqm[33].load("F:\\QTprint\\jqm\\34.png");
    m_jqm[34].load("F:\\QTprint\\jqm\\35.png");
    m_jqm[35].load("F:\\QTprint\\jqm\\36.png");
    m_jqm[36].load("F:\\QTprint\\jqm\\37.png");
    m_jqm[37].load("F:\\QTprint\\jqm\\38.png");
    m_jqm[38].load("F:\\QTprint\\jqm\\39.png");
    m_jqm[39].load("F:\\QTprint\\jqm\\40.png");
    m_jqm[40].load("F:\\QTprint\\jqm\\41.png");
    m_jqm[41].load("F:\\QTprint\\jqm\\42.png");
    m_jqm[42].load("F:\\QTprint\\jqm\\43.png");
    m_jqm[43].load("F:\\QTprint\\jqm\\44.png");
    m_jqm[44].load("F:\\QTprint\\jqm\\45.png");
    m_jqm[45].load("F:\\QTprint\\jqm\\46.png");
    m_jqm[46].load("F:\\QTprint\\jqm\\47.png");
    m_jqm[47].load("F:\\QTprint\\jqm\\48.png");
    m_jqm[48].load("F:\\QTprint\\jqm\\49.png");
    m_jqm[49].load("F:\\QTprint\\jqm\\50.png");
    m_jqm[50].load("F:\\QTprint\\jqm\\51.png");
    m_jqm[51].load("F:\\QTprint\\jqm\\52.png");
    m_jqm[52].load("F:\\QTprint\\jqm\\53.png");
    m_jqm[53].load("F:\\QTprint\\jqm\\54.png");
    m_jqm[54].load("F:\\QTprint\\jqm\\55.png");
    m_jqm[55].load("F:\\QTprint\\jqm\\56.png");
    m_jqm[56].load("F:\\QTprint\\jqm\\57.png");
    m_jqm[57].load("F:\\QTprint\\jqm\\58.png");
    m_jqm[58].load("F:\\QTprint\\jqm\\59.png");
    m_jqm[59].load("F:\\QTprint\\jqm\\60.png");
    m_jqm[60].load("F:\\QTprint\\jqm\\61.png");
    m_jqm[61].load("F:\\QTprint\\jqm\\62.png");
    m_jqm[62].load("F:\\QTprint\\jqm\\63.png");
    m_jqm[63].load("F:\\QTprint\\jqm\\64.png");
    m_jqm[64].load("F:\\QTprint\\jqm\\65.png");
    m_jqm[65].load("F:\\QTprint\\jqm\\66.png");
    m_jqm[66].load("F:\\QTprint\\jqm\\67.png");
    m_jqm[67].load("F:\\QTprint\\jqm\\68.png");
    m_jqm[68].load("F:\\QTprint\\jqm\\69.png");
    m_jqm[69].load("F:\\QTprint\\jqm\\70.png");
    m_jqm[70].load("F:\\QTprint\\jqm\\71.png");
    m_jqm[71].load("F:\\QTprint\\jqm\\72.png");




mus->m_time_1->setInterval(100);
    mus->m_time_1->setTimerType(Qt::PreciseTimer);
    add =0;
     m_Poxmap[0].load(":/mp3/199.png");
     m_Poxmap[1].load(":/mp3/200.png");
     m_Poxmap[2].load(":/mp3/201.png");
     m_Poxmap[3].load(":/mp3/202.png");
     m_Poxmap[4].load(":/mp3/203.png");
     m_Poxmap[5].load(":/mp3/204.png");
     m_Poxmap[6].load(":/mp3/205.png");
     m_Poxmap[7].load(":/mp3/206.png");
     m_Poxmap[8].load(":/mp3/207.png");
     m_Poxmap[9].load(":/mp3/208.png");
     m_Poxmap[10].load(":/mp3/209.png");
     m_Poxmap[11].load(":/mp3/210.png");
     m_Poxmap[12].load(":/mp3/211.png");
     m_Poxmap[13].load(":/mp3/212.png");
     m_Poxmap[14].load(":/mp3/213.png");
     m_Poxmap[15].load(":/mp3/214.png");
     m_Poxmap[16].load(":/mp3/215.png");
     m_Poxmap[17].load(":/mp3/216.png");
     m_Poxmap[18].load(":/mp3/217.png");
     m_Poxmap[19].load(":/mp3/218.png");
     m_Poxmap[20].load(":/mp3/219.png");
     m_Poxmap[21].load(":/mp3/220.png");
     m_Poxmap[22].load(":/mp3/221.png");
    connect(mus->m_time_1,&QTimer::timeout,this,[=](){
        if(mus->player->state()== mus->player->PlayingState)
        {
            if(add == 22){
                add = 0;
            }
            ui->label_mus->setPixmap(m_Poxmap[add]);
            add++;
          //qDebug() << "定时器时间到";
        }
    });


    ui->label_mus->setPixmap(mus->muspix);
    camera = new QCamera(this);
    viewfinder = new QCameraViewfinder(this);
    imageCapture = new QCameraImageCapture(camera);
    ui->label_mus->setPixmap(QPixmap(":/Note.png"));

    ui->camera_1->addWidget(viewfinder);
     // 将 QCamera 的视频输出设置到 QCameraViewfinder
    camera->setViewfinder(viewfinder);


    connect(ui->pushButton, &QPushButton::clicked, this, &Widget_funcC_Smart_Home::toggleCamera);
    connect(ui->verticalSlider,&QSlider::valueChanged,[=](int value){
       mus->player->setVolume(value);
    });
    ui->ison_1->setGeometry(65,5,40,30);
    ui->ison_2->setGeometry(65,5,40,30);
    ui->ison_3->setGeometry(65,5,40,30);
    ui->ison_4->setGeometry(65,5,40,30);
    ui->ison_5->setGeometry(65,5,40,30);
    ui->ison_6->setGeometry(65,5,40,30);
    ui->ison_7->setGeometry(65,5,40,30);
    ui->ison_8->setGeometry(65,5,40,30);
    ui->ison_9->setGeometry(65,5,40,30);
    ui->ison_10->setGeometry(65,5,40,30);
    ui->label_pix_1->setPixmap(QPixmap(":/saodi_is"));
    ui->label_pix_2->setPixmap(QPixmap(":/lu_on"));
    ui->label_pix_3->setPixmap(QPixmap(":/chuang_on"));
    ui->label_pix_4->setPixmap(QPixmap(":/bingxiang_on"));
    ui->label_pix_5->setPixmap(QPixmap(":/kong_on"));
    ui->label_pix_6->setPixmap(QPixmap(":/deng_on"));
    ui->label_pixzong_1->setPixmap(QPixmap(":/kong_on"));
    ui->label_pixzong_2->setPixmap(QPixmap(":/deng_on"));
    ui->label_pixzong_3->setPixmap(QPixmap(":/chuang_on"));
    ui->label_pixzong_4->setPixmap(QPixmap(":/deng_on"));
    ui->label_pixzong_5->setPixmap(QPixmap(":/saodi_on"));
    ui->label_pixzong_6->setPixmap(QPixmap(":/chuang_on"));
    ui->label_pixzong_7->setPixmap(QPixmap(":/deng_on"));
    ui->label_pixzong_8->setPixmap(QPixmap(":/chuang_is"));
    ui->label_pixzong_9->setPixmap(QPixmap(":/deng_is"));
    connect(ui->ison_1, &button_home_put::stateChanged,
            this, &Widget_funcC_Smart_Home::put_ison_1);
    connect(ui->ison_2, &button_home_put::stateChanged,
            this, &Widget_funcC_Smart_Home::put_ison_2);
    connect(ui->ison_3, &button_home_put::stateChanged,
            this, &Widget_funcC_Smart_Home::put_ison_3);
    connect(ui->ison_4, &button_home_put::stateChanged,
            this, &Widget_funcC_Smart_Home::put_ison_4);
    connect(ui->ison_5, &button_home_put::stateChanged,
            this, &Widget_funcC_Smart_Home::put_ison_5);
    connect(ui->ison_6, &button_home_put::stateChanged,
            this, &Widget_funcC_Smart_Home::put_ison_6);
    connect(ui->ison_7, &button_home_put::stateChanged,
            this, &Widget_funcC_Smart_Home::put_ison_7);

    connect(ui->ison_8, &button_home_put::stateChanged,
            this, &Widget_funcC_Smart_Home::put_ison_8);
    connect(ui->ison_9, &button_home_put::stateChanged,
            this, &Widget_funcC_Smart_Home::put_ison_9);
    connect(ui->ison_10, &button_home_put::stateChanged,
            this, &Widget_funcC_Smart_Home::put_ison_10);
    //音乐播放器
    ui->Button_music->setIcon(QPixmap(":/bofang.png"));
    ui->fang_Button->setIcon(QPixmap(":/fang.png"));
    ui->Button_light->setIcon(QPixmap(":/light.png"));
    ui->Button_right->setIcon(QPixmap(":/right.png"));
    connect(mus->player,SIGNAL(durationChanged(qint64)),this,SLOT(durationChangedSlot(qint64)));
    connect(mus->player,SIGNAL(positionChanged(qint64)),this,SLOT(positionChangedSlot(qint64)));


}

Widget_funcC_Smart_Home::~Widget_funcC_Smart_Home()
{
    delete camera;
    delete viewfinder;
    delete imageCapture;
    delete mus;
    delete ui;
}

void Widget_funcC_Smart_Home::toggleCamera()
{
    if (camera->state() == QCamera::ActiveState) {

        camera->stop();
        ui->pushButton->setText("开始");
     } else {

         camera->start();
        ui->pushButton->setText("停止");
     }
    //camera->start();
}

void Widget_funcC_Smart_Home::put_ison_1(bool isOn)
{
    if(isOn){
        ui->label_pixzong_1->setPixmap(QPixmap(":/kong_on"));
        ui->label_pixzong_2->setPixmap(QPixmap(":/deng_on"));

        ui->label_fn_6->setText("ON");
        if(ui->ison_10->isOn == false){
            ui->ison_10->isOn = true;
        }
        ui->ison_10->setPixmap(QPixmap(":/ison_on"));
        ui->label_pix_6->setPixmap(QPixmap(":/deng_on"));

        ui->label_fn_5->setText("ON");
        if(ui->ison_9->isOn == false){
            ui->ison_9->isOn = true;
        }
        ui->ison_9->setPixmap(QPixmap(":/ison_on"));
        ui->label_pix_5->setPixmap(QPixmap(":/kong_on"));

    }else{
        if(ui->ison_2->isOn == false){
            ui->ison_2->isOn = true;
        }

        ui->label_pixzong_3->setPixmap(QPixmap(":/chuang_on"));
        ui->label_pixzong_4->setPixmap(QPixmap(":/deng_on"));
        ui->label_pixzong_5->setPixmap(QPixmap(":/saodi_is"));

        ui->ison_2->setPixmap(QPixmap(":/ison_on"));

        ui->label_pixzong_1->setPixmap(QPixmap(":/kong_is"));
        ui->label_pixzong_2->setPixmap(QPixmap(":/deng_is"));

        ui->label_fn_6->setText("OFF");
        if(ui->ison_10->isOn == true){
            ui->ison_10->isOn = false;
        }
        ui->ison_10->setPixmap(QPixmap(":/ison_is"));
        ui->label_pix_6->setPixmap(QPixmap(":/deng_is"));

        ui->label_fn_5->setText("OFF");
        if(ui->ison_9->isOn == true){
            ui->ison_9->isOn = false;
        }
        ui->ison_9->setPixmap(QPixmap(":/ison_is"));
        ui->label_pix_5->setPixmap(QPixmap(":/kong_is"));

        ui->label_fn_1->setText("ON");
        if(ui->ison_9->isOn == true){
            ui->ison_9->isOn = false;
        }
        ui->ison_5->setPixmap(QPixmap(":/ison_on"));
        ui->label_pix_1->setPixmap(QPixmap(":/saodi_is"));
    }
}

void Widget_funcC_Smart_Home::put_ison_2(bool isOn)
{
    if(isOn){

        ui->label_pixzong_3->setPixmap(QPixmap(":/chuang_is"));
        ui->label_pixzong_4->setPixmap(QPixmap(":/deng_is"));
        ui->label_pixzong_5->setPixmap(QPixmap(":/saodi_is"));


        ui->label_fn_6->setText("OFF");
        if(ui->ison_10->isOn == true){
            ui->ison_10->isOn = false;
        }
        ui->ison_10->setPixmap(QPixmap(":/ison_is"));
        ui->label_pix_6->setPixmap(QPixmap(":/deng_is"));

        ui->label_fn_3->setText("OFF");
        if(ui->ison_7->isOn == true){
            ui->ison_7->isOn = false;
        }
        ui->ison_7->setPixmap(QPixmap(":/ison_is"));
        ui->label_pix_3->setPixmap(QPixmap(":/chuang_is"));

        ui->label_fn_1->setText("ON");
        if(ui->ison_5->isOn == false){
            ui->ison_5->isOn = true;
        }

        ui->ison_5->setPixmap(QPixmap(":/ison_on"));
        ui->label_pix_1->setPixmap(QPixmap(":/saodi_is"));
    }else{
        if(ui->ison_1->isOn == false){
            ui->ison_1->isOn = true;
        }
        ui->ison_1->setPixmap(QPixmap(":/ison_on"));


        ui->label_pixzong_1->setPixmap(QPixmap(":/kong_on"));
        ui->label_pixzong_2->setPixmap(QPixmap(":/deng_on"));

        ui->label_fn_1->setText("OFF");
        if(ui->ison_5->isOn == true){
            ui->ison_5->isOn = false;
        }

        ui->ison_5->setPixmap(QPixmap(":/ison_is"));
        ui->label_pix_1->setPixmap(QPixmap(":/saodi_on"));

        ui->label_fn_6->setText("ON");
        if(ui->ison_10->isOn == false){
            ui->ison_10->isOn = true;
        }
        ui->ison_10->setPixmap(QPixmap(":/ison_on"));
        ui->label_pix_6->setPixmap(QPixmap(":/deng_on"));

        ui->label_fn_3->setText("ON");
        if(ui->ison_7->isOn == false){
            ui->ison_7->isOn = true;
        }
        ui->ison_7->setPixmap(QPixmap(":/ison_on"));
        ui->label_pix_3->setPixmap(QPixmap(":/chuang_on"));

        ui->label_fn_5->setText("ON");
        if(ui->ison_9->isOn == false){
            ui->ison_9->isOn = true;
        }
        ui->ison_9->setPixmap(QPixmap(":/ison_on"));
        ui->label_pix_5->setPixmap(QPixmap(":/kong_on"));

        ui->label_pixzong_3->setPixmap(QPixmap(":/chuang_on"));
        ui->label_pixzong_4->setPixmap(QPixmap(":/deng_on"));
        ui->label_pixzong_5->setPixmap(QPixmap(":/saodi_on"));
    }
}

void Widget_funcC_Smart_Home::put_ison_3(bool isOn)
{
    if(isOn){

        ui->label_pixzong_6->setPixmap(QPixmap(":/chuang_on"));
        ui->label_pixzong_7->setPixmap(QPixmap(":/deng_on"));

        ui->label_fn_6->setText("ON");
        if(ui->ison_10->isOn == false){
            ui->ison_10->isOn = true;
        }
        ui->ison_10->setPixmap(QPixmap(":/ison_on"));
        ui->label_pix_6->setPixmap(QPixmap(":/deng_on"));

        ui->label_fn_3->setText("ON");
        if(ui->ison_7->isOn == false){
            ui->ison_7->isOn = true;
        }
        ui->ison_7->setPixmap(QPixmap(":/ison_on"));
        ui->label_pix_3->setPixmap(QPixmap(":/chuang_on"));

    }else{

        if(ui->ison_4->isOn == false){
            ui->ison_4->isOn = true;
        }
        ui->ison_4->setPixmap(QPixmap(":/ison_on"));
        ui->label_pixzong_8->setPixmap(QPixmap(":/chuang_is"));
        ui->label_pixzong_9->setPixmap(QPixmap(":/deng_is"));

        ui->label_pixzong_6->setPixmap(QPixmap(":/chuang_is"));
        ui->label_pixzong_7->setPixmap(QPixmap(":/deng_is"));

        ui->label_fn_6->setText("OFF");
        if(ui->ison_10->isOn == true){
            ui->ison_10->isOn = false;
        }
        ui->ison_10->setPixmap(QPixmap(":/ison_is"));
        ui->label_pix_6->setPixmap(QPixmap(":/deng_is"));

        ui->label_fn_3->setText("OFF");
        if(ui->ison_7->isOn == true){
            ui->ison_7->isOn = false;
        }
        ui->ison_7->setPixmap(QPixmap(":/ison_is"));
        ui->label_pix_3->setPixmap(QPixmap(":/chuang_is"));
    }
}

void Widget_funcC_Smart_Home::put_ison_4(bool isOn)
{
    if(isOn){

        ui->label_pixzong_8->setPixmap(QPixmap(":/chuang_is"));
        ui->label_pixzong_9->setPixmap(QPixmap(":/deng_is"));

        ui->label_fn_6->setText("OFF");
        if(ui->ison_10->isOn == true){
            ui->ison_10->isOn = false;
        }
        ui->ison_10->setPixmap(QPixmap(":/ison_is"));
        ui->label_pix_6->setPixmap(QPixmap(":/deng_is"));

        ui->label_fn_3->setText("OFF");
        if(ui->ison_7->isOn == true){
            ui->ison_7->isOn = false;
        }
        ui->ison_7->setPixmap(QPixmap(":/ison_is"));
        ui->label_pix_3->setPixmap(QPixmap(":/chuang_is"));

    }else{
        ui->label_pixzong_6->setPixmap(QPixmap(":/chuang_on"));
        ui->label_pixzong_7->setPixmap(QPixmap(":/deng_on"));

        if(ui->ison_3->isOn == false){
            ui->ison_3->isOn = true;
        }
        ui->ison_3->setPixmap(QPixmap(":/ison_on"));
        ui->label_pixzong_8->setPixmap(QPixmap(":/chuang_on"));
        ui->label_pixzong_9->setPixmap(QPixmap(":/deng_on"));

        ui->label_fn_6->setText("ON");
        if(ui->ison_10->isOn == false){
            ui->ison_10->isOn = true;
        }
        ui->ison_10->setPixmap(QPixmap(":/ison_on"));
        ui->label_pix_6->setPixmap(QPixmap(":/deng_on"));

        ui->label_fn_3->setText("ON");
        if(ui->ison_7->isOn == false){
            ui->ison_7->isOn = true;
        }
        ui->ison_7->setPixmap(QPixmap(":/ison_on"));
        ui->label_pix_3->setPixmap(QPixmap(":/chuang_on"));
    }
}

void Widget_funcC_Smart_Home::put_ison_5(bool isOn)
{
    if(isOn){
        ui->label_pix_1->setPixmap(QPixmap(":/saodi_is"));
        ui->label_fn_1->setText("NO");
    }else{
        ui->label_pix_1->setPixmap(QPixmap(":/saodi_on"));
        ui->label_fn_1->setText("OFF");
    }
}

void Widget_funcC_Smart_Home::put_ison_6(bool isOn)
{
    if(isOn){
        ui->label_pix_2->setPixmap(QPixmap(":/lu_on"));
        ui->label_fn_2->setText("NO");
    }else{
        ui->label_pix_2->setPixmap(QPixmap(":/lu_is"));
        ui->label_fn_2->setText("OFF");
    }
}

void Widget_funcC_Smart_Home::put_ison_7(bool isOn)
{
    if(isOn){
        ui->label_pix_3->setPixmap(QPixmap(":/chuang_on"));
        ui->label_fn_3->setText("NO");
    }else{
        ui->label_pix_3->setPixmap(QPixmap(":/chuang_is"));
        ui->label_fn_3->setText("OFF");
    }
}

void Widget_funcC_Smart_Home::put_ison_8(bool isOn)
{
    if(isOn){
        ui->label_pix_4->setPixmap(QPixmap(":/bingxiang_on"));
        ui->label_fn_4->setText("NO");
    }else{
        ui->label_pix_4->setPixmap(QPixmap(":/bingxiang_is"));
        ui->label_fn_4->setText("OFF");
    }
}

void Widget_funcC_Smart_Home::put_ison_9(bool isOn)
{
    if(isOn){
        ui->label_pix_5->setPixmap(QPixmap(":/kong_on"));
        ui->label_fn_5->setText("NO");
    }else{
        ui->label_pix_5->setPixmap(QPixmap(":/kong_is"));
        ui->label_fn_5->setText("OFF");
    }
}

void Widget_funcC_Smart_Home::put_ison_10(bool isOn)
{
    if(isOn){
        ui->label_pix_6->setPixmap(QPixmap(":/deng_on"));
        ui->label_fn_6->setText("NO");
    }else{
        ui->label_pix_6->setPixmap(QPixmap(":/deng_is"));
        ui->label_fn_6->setText("OFF");
    }
}




void Widget_funcC_Smart_Home::on_fang_Button_clicked()
{
    mus->show();
}


void Widget_funcC_Smart_Home::positionChangedSlot(qint64 position)
{
    ui->horizontalSlider->setValue(position);
     int totalSeconds2 = position / 1000; // 转换为秒
     int minutes2 = totalSeconds2 / 60;
     int seconds2 = totalSeconds2 % 60;
     QString currentTimeLabel2 = QString("%1:%2").arg(minutes2, 2, 10, QChar('0')).arg(seconds2, 2, 10, QChar('0'));

     ui->label_12->setText(currentTimeLabel2);
}

void Widget_funcC_Smart_Home::durationChangedSlot(qint64 duration)
{
    qDebug()<<"当前歌曲的总时长为"<<duration<<"毫秒"<<endl;
    ui->horizontalSlider->setRange(0,duration);

    int totalSeconds = duration / 1000; // 转换为秒
    int minutes = totalSeconds / 60;
    int seconds = totalSeconds % 60;
    QString totalTimeString = QString("%1:%2").arg(minutes, 2, 10, QChar('0')).arg(seconds, 2, 10, QChar('0'));

    ui->label_13->setText(totalTimeString);
}

void Widget_funcC_Smart_Home::on_horizontalSlider_sliderReleased()
{
    qint64 var = ui->horizontalSlider->value();//得到滑块当前值
    mus->player->setPosition(var);//得到滑块当前值做为音乐播放的当前时间
}



void Widget_funcC_Smart_Home::on_Button_music_clicked()
{
    if(mus->player->state()== mus->player->PlayingState)
    {
        ui->Button_music->setIcon(QPixmap(":/bofang.png"));
        mus->player->pause();
       mus-> m_time_1->stop();
        if(mus->m_time_1->isActive()==false){
            qDebug() << "定时器已关闭";
        }else{
            qDebug() << "定时器已关闭失败";
        }

    }
    else
    {
        ui->Button_music->setIcon(QPixmap(":/img/bof.png"));
        mus->player->play();
        mus->m_time_1->start();
        if(mus->m_time_1->isActive()==true){
            if(add ==22 ){
                add = 0;
            }
            ui->label_mus->setPixmap(m_Poxmap[add]);
            add++;
            qDebug() << "定时器已启动";
        }else{
            qDebug() << "定时器启动失败";
        }

    }
}

void Widget_funcC_Smart_Home::on_Button_light_clicked()
{
    int count = mus->playlist->mediaCount(); // 判断音乐的个数
        if(count == 0)
        {
            return;
        }
        ui->horizontalSlider->setValue(0);
        /* 跳转到列表的上一个 */
        mus->playlist->previous();

        mus->player->play(); // 播放音乐
        mus->m_time_1->start();
}

void Widget_funcC_Smart_Home::on_Button_right_clicked()
{
    int count = mus->playlist->mediaCount(); // 判断音乐的个数
        if(count == 0)
        {
            return;
        }
        ui->horizontalSlider->setValue(0);
        /* 跳转到列表的下一个 */
        mus->playlist->next();

        mus->player->play(); // 播放音乐
        mus->m_time_1->start();
}





void Widget_funcC_Smart_Home::on_pushButton_2_clicked()
{
    ui->pushButton_2->hide();
     mp4player->stop();
    mp4timer->stop();
    jqmtimer->start();
    connect(this->jqmtimer,&QTimer::timeout,this,[=](){

        if(jqmadd == 71){
            jqmadd = 0;
        }
        ui->label_mp3->setPixmap(m_jqm[jqmadd]);
        jqmadd++;
          //qDebug() << "定时器时间到";
    });
}
